<!--
 * @Author: hucc
 * @Date: 2021-10-15 14:05:13
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-16 20:14:41
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/qs.js"></script>
    <script>
        const qs = Qs;
        const baseUrl = "http://39.103.202.53:8888"
        const queryData = {
                page: 1,
                pageSize: 10
            }
            //1.实例化http请求对象
        let xhr = new XMLHttpRequest()
            //2.打开连接，设置请求的配置参数 get参数可以拼接在url后面，而且是查询字符串的格式 ? &进行拼接
        const qsData = qs.stringify(queryData); //转成查询字符串进行拼接
        console.log(qsData);
        xhr.open('get', baseUrl + '/index/article/pageQuery' + '?' + qsData)
            //3.发送数据并且配置请求体 post配置请求体
        xhr.send();
        //4.监听Http连接状态的改变 获取响应
        xhr.onreadystatechange = () => {
            if (xhr.readyState === 4 && xhr.status === 200) {
                console.log(JSON.parse(xhr.response));
                //console.log(JSON.parse(xhr.responseText));
            }
        }
    </script>
</head>

<body>

</body>

</html>